package org.apache.rocketmq.client.java.rpc;



import apache.rocketmq.v2.*;
import com.google.common.util.concurrent.ListenableFuture;
import io.grpc.Metadata;
import io.grpc.stub.StreamObserver;

import java.time.Duration;
import java.util.Iterator;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;

/**
 * @课程描述:从零带你写框架系列中的课程，整个系列包含netty，xxl-job，rocketmq，nacos，sofajraft，spring，springboot，disruptor，编译器，虚拟机等等。
 * @author：陈清风扬，个人微信号：chenqingfengyangjj。
 * @date:2025/6/10
 * @方法描述：rpc客户端接口
 */
public interface RpcClient {

    Duration idleDuration();

    void shutdown() throws InterruptedException;

    ListenableFuture<RpcInvocation<QueryRouteResponse>> queryRoute(Metadata metadata, QueryRouteRequest request,
                                                                   Executor executor,
                                                                   Duration duration);
    ListenableFuture<RpcInvocation<HeartbeatResponse>> heartbeat(Metadata metadata, HeartbeatRequest request,
                                                                 Executor executor,
                                                                 Duration duration);
    ListenableFuture<RpcInvocation<SendMessageResponse>> sendMessage(Metadata metadata,
                                                                     SendMessageRequest request, Executor executor, Duration duration);

    ListenableFuture<RpcInvocation<QueryAssignmentResponse>> queryAssignment(Metadata metadata,
                                                                             QueryAssignmentRequest request, Executor executor, Duration duration);

    ListenableFuture<RpcInvocation<Iterator<ReceiveMessageResponse>>> receiveMessage(Metadata metadata,
                                                                                     ReceiveMessageRequest request, ExecutorService executor, Duration duration);

    ListenableFuture<RpcInvocation<AckMessageResponse>> ackMessage(Metadata metadata, AckMessageRequest request,
                                                                   Executor executor, Duration duration);

    ListenableFuture<RpcInvocation<ChangeInvisibleDurationResponse>> changeInvisibleDuration(Metadata metadata,
                                                                                             ChangeInvisibleDurationRequest request, Executor executor, Duration duration);

    ListenableFuture<RpcInvocation<ForwardMessageToDeadLetterQueueResponse>> forwardMessageToDeadLetterQueue(
            Metadata metadata, ForwardMessageToDeadLetterQueueRequest request, Executor executor, Duration duration);

    ListenableFuture<RpcInvocation<EndTransactionResponse>> endTransaction(Metadata metadata,
                                                                           EndTransactionRequest request, Executor executor, Duration duration);

    ListenableFuture<RpcInvocation<NotifyClientTerminationResponse>> notifyClientTermination(Metadata metadata,
                                                                                             NotifyClientTerminationRequest request, Executor executor, Duration duration);

    StreamObserver<TelemetryCommand> telemetry(Metadata metadata, Executor executor, Duration duration,
                                               StreamObserver<TelemetryCommand> responseObserver);
}

